#include "threadpool.h"

ThreadPool::ThreadPool(int n)
{
     index=0;
     for(int i=0;i<n;i++){
        workerthread*pa=new workerthread();
        thread.push_back(pa);
     } 
}

void ThreadPool::Run()
{
    for(int i=0;i<thread.size();i++){
        thread[i]->run();
    }
}

EpollReactor* ThreadPool::TakeReactor()
{
    EpollReactor*reactor=thread[index%getthreadnum()]->GetReactor();
    this->index++;
    return reactor;
}
